package com.heima.wemedia.controller.v1;

import com.heima.model.admin.adminDto.AdChannelDto;
import com.heima.model.admin.adminDto.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author shitou
 * @className WmchannelController
 * @description: 频道管理
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/channel")
public class WmchannelController {

    @Resource
    private WmChannelService wmChannelService;

    /**
     * 查询所有频道
     *
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAllChannels() {
        return wmChannelService.findAllChannels();
    }

    /**
     * 频道分页查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto) {
        return wmChannelService.findChannelList(dto);
    }


    /**
     * 频道修改
     *
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannelDto dto) {
        return wmChannelService.updateChannel(dto);
    }

    /**
     * 频道新增
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannelDto dto) {
        return wmChannelService.saveChannel(dto);
    }

    /**
     * 删除频道
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable Integer id) {
        return wmChannelService.delChannel(id);
    }

}
